package calculator;

import java.lang.reflect.InvocationTargetException;

public class ExpressionSolver {

	private OperationResolver operationSolver;

	public ExpressionSolver(OperationResolver operationSolver) {
		super();
		this.operationSolver = operationSolver;
	}

	public Integer solve(String... expression) throws NumberFormatException,
			NoSuchMethodException, IllegalAccessException,
			InvocationTargetException, OverflowException {
		while (expression.length > 1) {
			expression = operationSolver.resolve(expression);
		}
		return Integer.parseInt(expression[0]);
	}

}
